package com.masterclient.app.businessmodule.minemodule.cash.detail;

import android.graphics.Paint;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.eoner.baselib.widget.navgation.FCNavigationBar;
import com.eoner.baselibrary.utils.StringsUtils;
import com.eoner.managerlibrary.sobot.SobotManager;
import com.masterclient.app.R;
import com.masterclient.app.base.FCBusinessActivity;
import com.masterclient.app.businessmodule.minemodule.cash.bean.CashDetailBean;
import com.masterclient.app.businessmodule.minemodule.cash.bean.CashInfoBean;
import com.masterclient.app.businessmodule.minemodule.cash.contract.CashInfoContract;
import com.masterclient.app.businessmodule.minemodule.cash.contract.CashInfoPresenter;
import com.sobot.chat.SobotApi;
import com.sobot.chat.api.enumtype.SobotChatTitleDisplayMode;
import com.sobot.chat.api.model.Information;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * 作者：sean
 * 创建时间：2017/10/16 18:55
 * 功能说明：
 */

public class CashPayInfoActivity extends FCBusinessActivity<CashInfoPresenter> implements CashInfoContract.View {


    String id;
    @BindView(R.id.tv)
    TextView tv;
    @BindView(R.id.tv_account_name)
    TextView tvAccountName;
    @BindView(R.id.tv_account_num)
    TextView tvAccountNum;
    @BindView(R.id.tv_cash_no)
    TextView tvCashNo;
    @BindView(R.id.ll_invoice_type)
    LinearLayout llInvoiceType;
    @BindView(R.id.tv_apply_time)
    TextView tvApplyTime;
    @BindView(R.id.tv_status)
    TextView tvStatus;
    @BindView(R.id.tv_verify_time)
    TextView tvVerifyTime;
    @BindView(R.id.ll_verify_time)
    LinearLayout llVerifyTime;
    @BindView(R.id.tv_remit_time)
    TextView tvRemitTime;
    @BindView(R.id.ll_remit_time)
    LinearLayout llRemitTime;
    @BindView(R.id.tv_reason)
    TextView tvReason;
    @BindView(R.id.ll_reason)
    LinearLayout llReason;
    @BindView(R.id.ll_real_name)
    LinearLayout llRealName;
    @BindView(R.id.tv_real_name)
    TextView tvRealName;
    @BindView(R.id.ll_personal_id)
    LinearLayout llPersonalId;
    @BindView(R.id.tv_personal_id)
    TextView tvPersonalId;
    @BindView(R.id.service_txt0)
    TextView service_txt0;
    @BindView(R.id.service)
    TextView service;
    @BindView(R.id.service_layout)
    View service_layout;

    @Override
    protected int requireGetLayoutId() {
        return R.layout.activity_cash_pay_info;
    }

    @Override
    protected void requireSetCustomNavigationBar(FCNavigationBar navigationBar) {
        navigationBar.setTitle("提现详情");
    }

    @Override
    protected void requireInitUIAndData(Bundle savedInstanceState) {
        service.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG );
        service.getPaint().setAntiAlias(true);

        id = getBundleString("id");
        mPresenter.getBalanceCashInfo(id);
    }

    @OnClick({R.id.service})
    void onClick(View view) {
        switch (view.getId()) {
            case R.id.service:
                Information info = SobotManager.getBaseInfo();
                //SobotApi.setChatTitleDisplayMode(mContext, SobotChatTitleDisplayMode.ShowFixedText,"提现详情");
                SobotApi.setChatTitleDisplayMode(mContext, SobotChatTitleDisplayMode.Default, "");
                SobotApi.startSobotChat(mContext, info);
                break;
        }
    }

    @Override
    public void showData(CashInfoBean.DataBean dataBean) {
        tvAccountName.setText(dataBean.getSh_real_name());
        tvAccountNum.setText(dataBean.getSh_acount());
        tvApplyTime.setText(dataBean.getSh_create_at());
        tvCashNo.setText(dataBean.getSh_cash_no());
        tvRemitTime.setText(dataBean.getSh_done_at());
        tvVerifyTime.setText(dataBean.getSh_verify_at());
        tv.setText("-" + StringsUtils.keep2num(dataBean.getSh_amount()));
        tvStatus.setText(dataBean.getSh_status_label());
        tvReason.setText(dataBean.getSh_refuse_resaon());

        if(!TextUtils.isEmpty(dataBean.getSh_id_card_no())){
            tvPersonalId.setText(dataBean.getSh_id_card_no());
        }else {
            llPersonalId.setVisibility(View.GONE);
        }

        if(!TextUtils.isEmpty(dataBean.getSh_real_name())){
            llRealName.setVisibility(View.GONE);
            tvRealName.setText(dataBean.getSh_real_name());
        }else {
            llRealName.setVisibility(View.GONE);
        }
        switch (dataBean.getSh_status()) {//0待审核、1待打款、2已打款、3已拒绝、4打款失败
            case "0":
                llRemitTime.setVisibility(View.GONE);
                llReason.setVisibility(View.GONE);
                llVerifyTime.setVisibility(View.GONE);
                tvRemitTime.setVisibility(View.GONE);
                tvReason.setVisibility(View.GONE);
                tvVerifyTime.setVisibility(View.GONE);
                service_txt0.setText("审核结果会尽快给出");
                break;
            case "1":
                llRemitTime.setVisibility(View.GONE);
                llReason.setVisibility(View.GONE);
                tvRemitTime.setVisibility(View.GONE);
                tvReason.setVisibility(View.GONE);
                break;
            case "2":
                llReason.setVisibility(View.GONE);
                tvReason.setVisibility(View.GONE);
                llVerifyTime.setVisibility(View.GONE);
                //tvStatus.setTextColor(Color.parseColor("#39bf39"));
                service_layout.setVisibility(View.GONE);
                break;
            case "3":
                llRemitTime.setVisibility(View.GONE);
                tvRemitTime.setVisibility(View.GONE);
                llVerifyTime.setVisibility(View.GONE);
                llReason.setVisibility(View.GONE);
                //tvStatus.setTextColor(getResources().getColor(R.color.our_gongzhu_color));
                service_layout.setVisibility(View.GONE);
                break;
            case "4":
                llRemitTime.setVisibility(View.GONE);
                tvRemitTime.setVisibility(View.GONE);
                llVerifyTime.setVisibility(View.GONE);
                //tvStatus.setTextColor(getResources().getColor(R.color.our_gongzhu_color));
                break;
        }
    }

    @Override
    public void showCashDetailData(CashDetailBean.DataBean dataBean) {

    }

    @Override
    public void onClickPageStateErrorView() {
        super.onClickPageStateErrorView();
        mPresenter.getBalanceCashInfo(id);
    }

    @Override
    public void baseShowError() {
        super.baseShowError();
    }
}
